/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import util.JPAUtil;

/**
 *
 * @author Gilberto
 */
@Entity
@Table(name = "ecf_pre_venda_cabecalho")
public class PreVendaCabecalho implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Column(name = "DATA_PV")
    @Temporal(TemporalType.DATE)
    private Date dataPv;
    @Size(max = 8)
    @Column(name = "HORA_PV")
    private String horaPv;
    @Column(name = "SITUACAO")
    private Character situacao;
    @Column(name = "CCF")
    private Integer ccf;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "VALOR")
    private BigDecimal valor;

    public PreVendaCabecalho() {
    }

    public PreVendaCabecalho(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataPv() {
        return dataPv;
    }

    public void setDataPv(Date dataPv) {
        this.dataPv = dataPv;
    }

    public String getHoraPv() {
        return horaPv;
    }

    public void setHoraPv(String horaPv) {
        this.horaPv = horaPv;
    }

    public Character getSituacao() {
        return situacao;
    }

    public void setSituacao(Character situacao) {
        this.situacao = situacao;
    }

    public Integer getCcf() {
        return ccf;
    }

    public void setCcf(Integer ccf) {
        this.ccf = ccf;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PreVendaCabecalho)) {
            return false;
        }
        PreVendaCabecalho other = (PreVendaCabecalho) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.modelo.PreVendaCabecalho[ id=" + id + " ]";
    }

    public static List<PreVendaCabecalho> retornaPreVendaCabecalho() {
        EntityManager em = JPAUtil.retornarFabrica().createEntityManager();
        Query q = em.createQuery("FROM PreVendaCabecalho");
        List<PreVendaCabecalho> list = q.getResultList();
        em.close();
        return list;
    }

    public PreVendaCabecalho salvar() {
        return (PreVendaCabecalho) JPAUtil.mergeObjeto(this);
    }

    public void excluir() {
        JPAUtil.delete(this);
    }

    public static List<PreVendaCabecalho> retornaBusca(String campoBusca) {
        EntityManager em = JPAUtil.retornarFabrica().createEntityManager();
        Query q = em.createQuery("FROM PreVendaCabecalho");
        List<PreVendaCabecalho> list = q.getResultList();
        em.close();
        return list;
    }
}
